// g:\顾赫男\dyapp\test\master\TEST\pages\answer\answer.js
Page({
  data: {
      answers: [],
      number: 0,
      lists: [{
              question: '当你要外出一整天，你会',
              answers: [{
                      answer: '计划你要做什么和在什么时候做',
                      sign: 'J'
                  },
                  {
                      answer: '说去就去',
                      sign: 'P'
                  }
              ]
          },
          {
              question: '你认为自己是一个',
              answers: [{
                      answer: '较为随兴所至的人',
                      sign: 'P'
                  },
                  {
                      answer: '较为有条理的人',
                      sign: 'J'
                  }
              ]
          },
          {
              question: '一般来说，你和哪些人比较合得来？',
              answers: [{
                      answer: '富于想象力的人',
                      sign: 'N'
                  },
                  {
                      answer: '现实的人',
                      sign: 'S'
                  }
              ]
          },
          {
              question: '当你有一份特别的任务，你会喜欢',
              answers: [{
                      answer: '开始前小心组织计划',
                      sign: 'J'
                  },
                  {
                      answer: '边做边找须做什么',
                      sign: 'P'
                  }
              ]
          },
          {
              question: '在大多数情况下，你会选择',
              answers: [{
                      answer: '顺其自然',
                      sign: 'P'
                  },
                  {
                      answer: '按程序表做事',
                      sign: 'J'
                  }
              ]
          },
          {
              question: '大多数人会说你是一个',
              answers: [{
                      answer: '重视自我隐私的人',
                      sign: 'I'
                  },
                  {
                      answer: '非常坦率开放的人',
                      sign: 'E'
                  }
              ]
          },
          {
              question: '你喜欢花很多的时间',
              answers: [{
                      answer: '一个人独处',
                      sign: 'I'
                  },
                  {
                      answer: '和别人在一起',
                      sign: 'E'
                  }
              ]
          }, {
              question: '计划一个旅程时，你较喜欢',
              answers: [{
                      answer: '大部分的时间都是跟当天的感觉行事',
                      sign: 'P'
                  },
                  {
                      answer: '事先知道大部分的日子会做什么',
                      sign: 'J'
                  }
              ]
          }, {
              question: '在社交聚会中，你',
              answers: [{
                      answer: '有时感到郁闷',
                      sign: 'I'
                  },
                  {
                      answer: '常常乐在其中',
                      sign: 'E'
                  }
              ]
          }, {
              question: '你通常',
              answers: [{
                      answer: '和别人容易混熟',
                      sign: 'E'
                  },
                  {
                      answer: '趋向自处一隅',
                      sign: 'I'
                  }
              ]
          }, {
              question: '哪些人会更吸引你？',
              answers: [{
                      answer: '一个思想敏捷及非常聪颖的人',
                      sign: 'N'
                  },
                  {
                      answer: '实事求是，具丰富常识的人',
                      sign: 'S'
                  }
              ]
          }, {
              question: '在日常工作中，你会',
              answers: [{
                      answer: '颇为喜欢处理迫使你分秒必争的突发',
                      sign: 'P'
                  },
                  {
                      answer: '通常预先计划，以免要在压力下工作',
                      sign: 'J'
                  }
              ]
          }, {
              question: '你认为别人一般',
              answers: [{
                      answer: '要花很长时间才认识你',
                      sign: 'I'
                  },
                  {
                      answer: '用很短的时间便认识你',
                      sign: 'E'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '有条不紊',
                      sign: 'J'
                  },
                  {
                      answer: '不拘小节',
                      sign: 'P'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '意念',
                      sign: 'N'
                  },
                  {
                      answer: '实况',
                      sign: 'S'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '同情怜悯',
                      sign: 'F'
                  },
                  {
                      answer: '远见',
                      sign: 'T'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '富想象的',
                      sign: 'N'
                  },
                  {
                      answer: '以事论事',
                      sign: 'S'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '亲切的',
                      sign: 'F'
                  },
                  {
                      answer: '客观的',
                      sign: 'T'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '客观的',
                      sign: 'T'
                  },
                  {
                      answer: '热情的',
                      sign: 'F'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '建造',
                      sign: 'S'
                  },
                  {
                      answer: '发明',
                      sign: 'N'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '文静',
                      sign: 'I'
                  },
                  {
                      answer: '爱合群',
                      sign: 'E'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '理论',
                      sign: 'N'
                  },
                  {
                      answer: '事实',
                      sign: 'S'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '富同情',
                      sign: 'F'
                  },
                  {
                      answer: '合逻辑',
                      sign: 'T'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '具分析力',
                      sign: 'T'
                  },
                  {
                      answer: '多愁善感',
                      sign: 'F'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '合情合理',
                      sign: 'S'
                  },
                  {
                      answer: '令人着迷',
                      sign: 'N'
                  }
              ]
          }, {
              question: '你刚认识的朋友能否说出你的兴趣？',
              answers: [{
                      answer: '马上可以',
                      sign: 'E'
                  },
                  {
                      answer: '要待他们真正了解你之后才可以',
                      sign: 'I'
                  }
              ]
          }, {
              question: '你通常较喜欢的科目是',
              answers: [{
                      answer: '讲授概念和原则的',
                      sign: 'N'
                  },
                  {
                      answer: '讲授事实和数据的',
                      sign: 'S'
                  }
              ]
          }, {
              question: '你认为按照程序表做事',
              answers: [{
                      answer: '有时是需要的，但一般来说你不大喜欢这样做',
                      sign: 'P'
                  },
                  {
                      answer: '大多数情况下是有帮助而且是你喜欢做的',
                      sign: 'J'
                  }
              ]
          }, {
              question: '和一群人在一起，你通常会选',
              answers: [{
                      answer: '跟你很熟悉的个别人谈话',
                      sign: 'I'
                  },
                  {
                      answer: '参与大伙的谈话',
                      sign: 'E'
                  }
              ]
          }, {
              question: '在社交聚会上，你会',
              answers: [{
                      answer: '是说话很多的一个人',
                      sign: 'E'
                  },
                  {
                      answer: '让别人多说话',
                      sign: 'I'
                  }
              ]
          }, {
              question: '把周末期间要完成的事列成清单，这个主意会',
              answers: [{
                      answer: '合你意',
                      sign: 'J'
                  },
                  {
                      answer: '使你提不起劲',
                      sign: 'P'
                  }
              ]
          }, {
              question: '总的说来，要做一个大型作业时，你会选',
              answers: [{
                      answer: '边做边想该做什么',
                      sign: 'P'
                  },
                  {
                      answer: '首先把工作按步细分',
                      sign: 'J'
                  }
              ]
          }, {
              question: '你宁愿替哪一类上司（或者老师）工作？',
              answers: [{
                      answer: '天性淳良，但常常前后不一的',
                      sign: 'T'
                  },
                  {
                      answer: '言词尖锐但永远合乎逻辑的',
                      sign: 'N'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '新颖的',
                      sign: 'N'
                  },
                  {
                      answer: '已知的',
                      sign: 'S'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '同情',
                      sign: 'F'
                  },
                  {
                      answer: '分析',
                      sign: 'T'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '坚持己见',
                      sign: 'T'
                  },
                  {
                      answer: '温柔有爱心',
                      sign: 'F'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '具体的',
                      sign: 'S'
                  },
                  {
                      answer: '抽象的',
                      sign: 'N'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '全心投入',
                      sign: 'F'
                  },
                  {
                      answer: '有决心的',
                      sign: 'T'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '能干',
                      sign: 'T'
                  },
                  {
                      answer: '仁慈',
                      sign: 'F'
                  }
              ]
          }, {
              question: '哪个词语更合你心意？',
              answers: [{
                      answer: '实际',
                      sign: 'S'
                  },
                  {
                      answer: '创新',
                      sign: 'N'
                  }
              ]
          }

      ],
      end: !1
  },
  onLoad: function(options) {

  },
  back() {
      var _ = this;
      var number = _.data.number;
      if (number > 0) {
          _.setData({
              number: number - 1
          })
      }

  },
  choose: function(e) {
      var _ = this;
      console.log(e.currentTarget.dataset.sign)
      console.log(_.data.number)
      var sign = e.currentTarget.dataset.sign;
      var number = _.data.number;
      var answers = _.data.answers;
      answers[number] = e.currentTarget.dataset.sign
      console.log(answers)
      _.setData({
          choose: e.currentTarget.dataset.sign
      })
      setTimeout(function() {
          if (number < 39) {
              _.setData({
                  number: number + 1,
                  choose: ''
              })
          } else {
              _.setData({
                  end: 1
              })
          }
      }, 500)


  },
  submit() {
      var _ = this;
      console.log(_.data.answers)
      var arr = _.data.answers;
      var E = 0,
          I = 0,
          S = 0,
          N = 0,
          T = 0,
          F = 0,
          J = 0,
          P = 0;
      var one, two, three, four;

      for (var a = 0, len = arr.length; a < len; a++) {
          switch (arr[a]) {
              case 'E':
                  E++
                  break;
              case 'I':
                  I++
                  break;
              case 'S':
                  S++
                  break;
              case 'N':
                  N++
                  break;
              case 'T':
                  T++
                  break;
              case 'F':
                  F++
                  break;
              case 'J':
                  J++
                  break;
              case 'P':
                  P++
                  break;
          }
      }
      console.log('E=' + E, 'I=' + I, 'S=' + S, 'N=' + N, 'T=' + T, 'F=' + F, 'J=' + J, 'P=' + P);

      if (E > I) {
          one = 'E'
      } else {
          one = 'I'
      }
      if (S > N) {
          two = 'S'
      } else {
          two = 'N'
      }
      if (T > F) {
          three = 'T'
      } else {
          three = 'F'
      }
      if (J > P) {
          four = 'J'
      } else {
          four = 'P'
      }
      var result = one + two + three + four
      console.log(result)
      wx.navigateTo({
          url: '../result/result?result=' + result,
      });
  },
  onShareAppMessage: function (res) {
    // do something
    return {
      //执行函数后，这里是需要该函数返回的对象
      title: "中公职业性格测试",
      path: '/pages/mbti/index/index',
      imageUrl: "https://sd.offcn.com/zg/wximg/2022/dy/psy/bg.jpg",
      success() {
        console.log("分享成功");
      },
      fail(e) {
        console.log("分享失败", e);
      },
    }; //返回的对象会传入wx.shareAppMessage进行最终分享
  }

})